#include <arpa/inet.h>
#include <netinet/in.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/socket.h>
#include <unistd.h>

#include "str_cli01.c"

#define SA struct sockaddr
#define SERV_PORT 8080

int main(int argc, char **argv) {
  int sockfd;
  struct sockaddr_in servaddr;
  int err;
  char *addr = "127.0.0.1";
  //    if (argc != 2)
  //        err_quit("usage: tcpcli <IPaddress>");

  sockfd = socket(AF_INET, SOCK_STREAM, 0);

  bzero(&servaddr, sizeof(servaddr));
  servaddr.sin_family = AF_INET;
  servaddr.sin_port = htons(SERV_PORT);
  inet_pton(AF_INET, addr, &servaddr.sin_addr);

  err = connect(sockfd, (SA *)&servaddr, sizeof(servaddr));

  if (err != 0) {
    printf("cannot connect to server address and port\n");
    exit(1);
  }
  str_cli(stdin, sockfd); /* do it all */

  exit(0);
}
